package com.yaorange.web.controller.nongjt;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.nongjt.domain.NjtPrinterManage;
import com.yaorange.nongjt.service.INjtPrinterManageService;
import com.yaorange.common.utils.poi.ExcelUtil;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 打印机设备管理Controller
 * 
 * @author zhouxin
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/nongjt/manage")
public class NjtPrinterManageController extends BaseController
{
    @Autowired
    private INjtPrinterManageService njtPrinterManageService;

    /**
     * 查询打印机设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtPrinterManage njtPrinterManage)
    {
        startPage();
        List<NjtPrinterManage> list = njtPrinterManageService.selectNjtPrinterManageList(njtPrinterManage);
        return getDataTable(list);
    }

    /**
     * 导出打印机设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:manage:export')")
    @Log(title = "打印机设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtPrinterManage njtPrinterManage)
    {
        List<NjtPrinterManage> list = njtPrinterManageService.selectNjtPrinterManageList(njtPrinterManage);
        ExcelUtil<NjtPrinterManage> util = new ExcelUtil<NjtPrinterManage>(NjtPrinterManage.class);
        util.exportExcel(response, list, "打印机设备管理数据");
    }

    /**
     * 获取打印机设备管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:manage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(njtPrinterManageService.selectNjtPrinterManageById(id));
    }

    /**
     * 新增打印机设备管理
     */
    @PreAuthorize("@ss.hasPermi('nongjt:manage:add')")
    @Log(title = "打印机设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtPrinterManage njtPrinterManage)
    {
        return toAjax(njtPrinterManageService.insertNjtPrinterManage(njtPrinterManage));
    }

    /**
     * 修改打印机设备管理
     */
    @PreAuthorize("@ss.hasPermi('nongjt:manage:edit')")
    @Log(title = "打印机设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtPrinterManage njtPrinterManage)
    {
        return toAjax(njtPrinterManageService.updateNjtPrinterManage(njtPrinterManage));
    }

    /**
     * 删除打印机设备管理
     */
    @PreAuthorize("@ss.hasPermi('nongjt:manage:remove')")
    @Log(title = "打印机设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(njtPrinterManageService.deleteNjtPrinterManageByIds(ids));
    }
}
